London | 26-ITP-Jan | Johnny Vargas | Sprint 3 | Practice TDD#1212
London | 26-ITP-Jan | Johnny Vargas | Sprint 3 | Practice TDD#1212JohnnyBoyV wants to merge 1 commit intoCodeYourFuture:mainfrom
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
-
Function implementation is correct.
-
Some test descriptions could be made clearer.
There was a problem hiding this comment.
Could consider testing a few more samples in this script - higher chance to detect bugs in code.
The original specification did not clearly state whether the character match should be case-sensitive.
Most people would probably assume that it is, but to demonstrate our understanding or clarify the assumption we made,
we could add test cases to convey this. For examples,
- A case to show that the match is case sensitive
- A case to show that the function is expected to work also for non-alphabets
There was a problem hiding this comment.
The test categories in this script do not yet cover all possible numbers.
| test("should print the string once", () => { | ||
| const str = "hello"; | ||
| const count = 1; | ||
| const repeatedStr = repeatStr(str, count); | ||
| expect(repeatedStr).toEqual("hello"); | ||
| }); | ||
|
|
||
| // Case: Handle count of 0: | ||
| // Given a target string `str` and a `count` equal to 0, | ||
| // When the repeatStr function is called with these inputs, | ||
| // Then it should return an empty string. | ||
| test("should print nothing", () => { |
There was a problem hiding this comment.
-
"print" would suggest the function is expected to output (instead of returning) the resulting string.
-
In TDD, the test description (or test name) should clearly explain what behavior the function should exhibit.
The goal is that someone reading the test can understand the requirement without reading another spec.
A common format is: should <expected_behavior> when <condition>.
Can you also include the "condition" part into these descriptions?
Learners, PR Template
Self checklist
Changelist
Did as asked for the Practice TDD.